package com.longshihan.news.service;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

import com.longshihan.news.control.KeepLiveActivityManager;
import com.longshihan.news.listener.ScreenListener;

/**
 * 监听屏幕关闭的服务
 */
public class OnePixcelService extends Service {
    public OnePixcelService() {
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        ScreenListener listener=new ScreenListener(this);
        listener.begin(new ScreenListener.ScreenStateListener() {
            @Override
            public void onScreenOn() {
                // 开屏---finish这个一个像素的Activity
                KeepLiveActivityManager.getInstance(OnePixcelService.this).finishKeepLiveActivity();

            }

            @Override
            public void onScreenOff() {

            }

            @Override
            public void onUserPresent() {
                // 锁屏---启动一个像素的Activity
                KeepLiveActivityManager.getInstance(OnePixcelService.this).startKeepLiveActivity();
            }
        });
    }
}
